package com.balabala.gym_goods.controller.app;

import com.balabala.gym_goods.pojo.dto.SpuQueryDto;
import com.balabala.gym_goods.pojo.entity.Spu;
import com.balabala.gym_goods.service.SpuService;
import com.balabala.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@CrossOrigin
@Api(tags = "积分商城接口")
@RequestMapping("/app/integral/spu")
public class SpuAppController {

    @Autowired
    private SpuService spuService;

    /*@ApiOperation(value = "查询所有商品")
    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
    public Result findAll() {
        List<Spu> spuList=spuService.list();
        return Result.ok(spuList);
    }
*/

    @ApiOperation(value = "根据商品id查询商品信息")
    @RequestMapping(value = "/findGoodInfoById", method = RequestMethod.GET)
    public Result findGoodInfoById(Long id) {
        Spu goodInfoById = spuService.findGoodInfoById(id);
        return Result.ok(goodInfoById);
    }

    @ApiOperation(value = "条件查询积分商城列表")
    @PostMapping(value = "/findGoodInfoById")
    public Result findGoodInfoById1(@RequestBody SpuQueryDto spuQueryDto) {

        List<Spu> listByDto = spuService.findListByDto(spuQueryDto);
        return Result.ok(listByDto);
    }
}
